{literal}
<script type="text/javascript" language="javascript">
var urlEditar = '{/literal}{$_site.url}{$urlEditar}{literal}';
var urlApagar = '{/literal}{$_site.url}{$urlApagar}{literal}';
function irPara(pag)
{
	document.form_busca.pag.value = pag;
	jqAjaxForm(document.form_busca, "div_tabela");
}
function anterior()
{
	irPara(parseInt(document.form_busca.pag.value)-1);
}
function proximo()
{
	irPara(parseInt(document.form_busca.pag.value)+1);
}
function editar(codigo)
{
	document.form_acao.action = urlEditar;
	document.form_acao.codigo.value = codigo;
	document.form_acao.acao.value = "editar";
	jqAjaxForm(document.form_acao, "div_form");
}
function excluir(codigo)
{
	document.form_acao.action = urlApagar;
	document.form_acao.codigo.value = codigo;
	document.form_acao.acao.value = "apagar";
	jqAjaxForm(document.form_acao, "div_form");
}

$("#lnkGerarCSV").click(function(){
	var params = $("#form_busca").serialize();
	window.location.href = "procedimento-atendimento/gerar-csv/?" + params;
});

</script>
{/literal}
	<form name="form_acao" id="form_acao" action="#" method="post">
		<input type="hidden" name="codigo" id="codigo" value=""/>
		<input type="hidden" name="acao" id="acao" value=""/>
	</form>
	<table width="100%" border="0" align="center" cellpadding="0" cellspacing="2" class="alpha">
      <tr>
        <td colspan="5" class="mvTituloFundo">Procedimentos de Atendimento</td>
      </tr>
      <tr>
        <td colspan="5" align="center">
	        <form name="form_busca" id="form_busca" action="{$_site.url}procedimento-atendimento/tabela" method="post" onsubmit="irPara(document.form_busca.pag.value); return false;">
	        	Num. Contrato: <input type="text" name="busca" id=busca" value="{$busca}" size="3" class="formulario"/>
	        	<input type="submit" value="Buscar" class="botao"/>
				<input type="hidden" name="pag" id="pag" value="{$pag}"/>
			</form>
		</td>
      </tr>
      <tr>
        <td colspan="5" align="center">
        	<div style="width:100%; postion:relative">
	        	<div style="text-align:center; width:85%; float:left"><b>{$total}</b> encontrados, exibindo de <b>{$inicio}</b> a <b>{$fim}</b></div>
	        	<div style="text-align:right; width:15%; float:right"><span id="lnkGerarCSV"><b>Exportar para</b> &nbsp;<img src="{$_site.url}/public/images/ic-xls.gif" border="0" align='top' style="cursor:pointer">&nbsp;</span></div>
        	</div>
		</td>
      </tr>
      <tr>
        <td valign="top" width="10%" class="paddingTotal3 bgCarla bold">Contrato</td>
        <td valign="top" width="25%" class="paddingTotal3 bgCarla bold">Display</td>
        <td valign="top" width="60%" class="paddingTotal3 bgCarla bold">Procedimento de Atendimento</td>
        <td colspan="2" align="center" valign="top" class="paddingTotal3 bgCarla bold">A&ccedil;&atilde;o</td>
      </tr>
      {foreach name=lista from=$procedimentos item=procedimento}
      <tr>
        <td valign="top" class="fundoTituloForm">{$procedimento->contrato_id}</td>
        <td width="200" valign="top" class="fundoTituloForm">{$procedimento->vhr_display_atendimento}</td>
        <td valign="top" class="fundoTituloForm">{$procedimento->txt_procedimento_atendimento|truncate:200:"...":false}</td>
        <td width="20" align="center" valign="top" class="fundoTituloForm"><a href="#" onclick="editar('{$procedimento->id}'); return false;"><img src="{$_site.url}public/images/ic-cadastrar.gif" alt="Alterar" border="0" title="Alterar"/></a></td>
        <td width="20" align="center" valign="top" class="fundoTituloForm"><a href="#" onclick="excluir('{$procedimento->id}'); return false;"><img src="{$_site.url}public/images/ic-excluir.gif" alt="Excluir" border="0" title="Excluir"/></a></td>
      </tr>
      {/foreach}
      <tr>
        <td colspan="4" align="center">{if $pag gt 1}
		<a href="#" onclick="irPara('1'); return false;"><<</a> 
		<a href="#" onclick="anterior(); return false;"><</a> 
	{else}
		<<  < 
	{/if}
	{section name=foo start=1 loop=$totalPag+1}
		{if $smarty.section.foo.index eq $pag}
			<font color="red">{$smarty.section.foo.index}</font>
		{else}
			<a href="#" onclick="irPara('{$smarty.section.foo.index}'); return false;">{$smarty.section.foo.index}</a>
		{/if}
		{if $smarty.section.foo.index lt $totalPag}
		|
		{/if}
	{/section}
	{if $pag lt $totalPag}
	<a href="#" onclick="proximo(); return false;">></a> 
	<a href="#" onclick="irPara('{$totalPag}'); return false;">>></a>
	{else}
	>  >>
	{/if}</td>
      </tr>
    </table>
